<?php

if (isset($_GET['patron_coding'])) {

include 'connect.php';

$interface = mysql_query("SELECT * FROM interface");
$interface_get= mysql_fetch_array( $interface) 
or die(mysql_error());



?>
<html>

<?php
include 'headerkiosk.php';
session_start();
//this checks for the get veriable out and if true displays an error
//it also qureys the 
//database for the book name if the barcode is true.
switch ($_GET['found']) {

case 'out' :
$bargo=$_GET['bar'];
$barcode = $_GET['bar'] ;
$book = mysql_query("SELECT * FROM books WHERE barcode= $bargo");
$book_get= mysql_fetch_array($book) 
or die(mysql_error());

echo '<h4><FONT COLOR="red">ERROR: The Book ' ;
echo $book_get['name'];
echo ' is already checked out under the barcode '; 
echo $_GET["bar"] ; 

break;

case 'checked-out':

echo '<h4><FONT COLOR="green">SUCCESS: The book </FONT><FONT COLOR="black">' ;
echo $_GET['bookname'];
echo ' </font><FONT COLOR="green">was checked out to</font><FONT COLOR="black"> '; 
echo $_GET['patron'];
echo ' </font><FONT COLOR="green">Under Barcode<FONT COLOR="black"> ';
echo $_GET['bar'];
echo ' </font><FONT COLOR="green">You can Check out another book now!</font>';
echo '</h4></font>';
array_push($_SESSION["books"],$_GET['bar']);


break;

case 'false' :

echo '<h4><FONT COLOR="red">ERROR: No Book was found under barcode ' ;
echo $_GET['bar'];
echo ' please verify the barcode you entered </h4></font>'; 

break;
case 'ready' :


echo '<h4><FONT COLOR="green">Ready for Check-Out Enter or Scan 12 Digit barcode now</h4></font>' ;

break;
}
 

echo date();
?>

<body
onLoad="self.focus();document.in.barcode.focus()"
>
<form action="checkout-gok.php" name="in" method="GET">
12 Digit Bar Code:   <input name="barcode" type="text" size="12" id="barcode" /><br>
12 Digit Patron Code: <b><?php echo $_GET["patron_coding"]; ?></b><input name="patroncode" type="text" size="12" value="<?php echo $_GET["patron_coding"]; ?>" hidden /><br>
<input type="submit" value="Checkout"/><br>
</form>
<form action="endsession.php" method="get">
<input type="submit" value="End Checkout Session!"/>
</form>
</body>
<?php
} 
else {
header("Location: index.php?checkempty=true");
}
?>